/*
 * Settings.java
 *
 * Created on Ketvirtadienis, 2006, Rugs�jo 28, 18.20
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package keitykla;

import j2mefs.*;
import java.io.*;
import java.util.Calendar;

public class Settings
{
    private static String from_currency;
    private static String to_currency; 
    
    /** Creates a new instance of Settings */
    public Settings()
    {
    }
    
//-----------------------------------------------------------------------------    
    
    public static String getFromCurrency()
    {
        String curr = null;
        String currency_from = "";
        Directory dir = Application.getSettingsDirectory();
        if(dir.fileExists("FROM"))
        {
            currency_from = Application.readFile("FROM",Application.getSettingsDirectory().getName());
            return currency_from;
        }
	return curr;
    }
    
//-----------------------------------------------------------------------------    
    
    public static String getToCurrency()
    {
        String curr = null;
        String currency_to = "";
        Directory dir = Application.getSettingsDirectory();
        if(dir.fileExists("TO"))
        {
            currency_to = Application.readFile("TO",Application.getSettingsDirectory().getName());
            return currency_to;
        }
	return curr;
    }
    
//-----------------------------------------------------------------------------    
    
    public static void setFromCurrency(String from_currency)
    {
        try
        {  
            Application.writeFile(Application.createOrLoadFile(Application.getSettingsDirectory(),"FROM"),from_currency);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
    
//-----------------------------------------------------------------------------    
    
    public static void setToCurrency(String to_currency)
    {
        try
        {
            Application.writeFile(Application.createOrLoadFile(Application.getSettingsDirectory(),"TO"),to_currency);
        }
        catch(Exception e)
        {
             e.printStackTrace();
        }
    }
    
//-----------------------------------------------------------------------------    
    
    public String getCurrencyNamesURL()
    {
        String http1 = Application.readFile("Names", Application.getSettingsDirectory().getName());

        return http1;
    }
    
//-----------------------------------------------------------------------------    
    
    public void setCurrencyNamesURL(String http1)
    {
        Application.writeFile(Application.createOrLoadFile(Application.getSettingsDirectory(),"Names"), http1);
    }    
    
//-----------------------------------------------------------------------------    
    
    public String getCurrencyRatesURL()
    {
        String http2 = Application.readFile("Rates", Application.getSettingsDirectory().getName());

        return http2;
    }
    
//-----------------------------------------------------------------------------    
    
    public void setCurrencyRatesURL(String http2)
    {
        Application.writeFile(Application.createOrLoadFile(Application.getSettingsDirectory(),"Rates"), http2);
    }    
    
//-----------------------------------------------------------------------------    
    
    public String getCurrencyRateURL()
    {
        String http3 = Application.readFile("Rate", Application.getSettingsDirectory().getName());

        return http3;
    }    
    
//-----------------------------------------------------------------------------    
    
    public void setCurrencyRateURL(String http3)
    {
        Application.writeFile(Application.createOrLoadFile(Application.getSettingsDirectory(),"Rate"), http3);
    }     
}
